package util
{
	import flash.display.BitmapData;
	import flash.geom.*;

	public class AnimationFactory
	{
		private static var _instance:AnimationFactory;
		public function AnimationFactory(singleton:singletonClass)
		{
		}
		
		public static function get instance():AnimationFactory {
			if(!_instance) {
				_instance = new AnimationFactory(new singletonClass());
			}
			return _instance;
		}
		
		/**
		 * 切图
		 * @param source : 原图
		 * @param row : 要切的行
		 * @param col : 要切的列
		 * @param width : 目标图的宽
		 * @param height : 目标图的高
		 */
		public function cutBitmapData(source:BitmapData,row:int,col:int,width:Number,height:Number):BitmapData {
			var bitmpaData:BitmapData = new BitmapData(width,height);
			bitmpaData.copyPixels(source,new Rectangle(col*width,row*height,width,height),new Point());
			return bitmpaData;
		}
		/**
		 * 切图
		 * @param source : 原图
		 * @param row : 要切的行
		 * @param cols : 要切多少列
		 * @param width : 目标图的宽
		 * @param height : 目标图的高
		 */
		public function cutBitmapDataArray(source:BitmapData,row:int,cols:int,width:Number,height:Number):Vector.<BitmapData> {
			var vector:Vector.<BitmapData> = new Vector.<BitmapData>();
			for(var i:int=0;i<cols;i++) {
				vector[i] = cutBitmapData(source,row,i,width,height);
			}
			return vector;
		
		}
	}
}
class singletonClass{}